package main.util;

import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据库操作工具类
 */
public class DBUtils {

    // JDBC连接信息
    private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
    private static final String JDBC_URL = "jdbc:oracle:thin:@localhost:1521:orcl";
    private static final String USERNAME = "TEST";
    private static final String PASSWORD = "1qaz@WSX";

    // 获取数据库连接
    static Connection getConn() throws SQLException {
        try {
            // 加载数据库驱动
            Class.forName(JDBC_DRIVER);
        } catch (ClassNotFoundException e) {
            throw new SQLException("数据库连接错误: 驱动加载失败");
        }

        // 创建数据库连接
        try {
            return DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);
        } catch (SQLException e) {
            throw new SQLException("数据库连接错误: " + e.getMessage());
        }
    }
}